//
//  KZPronounceNetApi.m
//  听说弱点强化训练
//
//  Created by 朱凯 on 2018/8/27.
//  Copyright © 2018年 盛超. All rights reserved.
//

#import "KZPronounceNetApi.h"



@implementation KZPronounceNetApi

// 获取待复习音标信息
- (void)getStandarPronouncationInfo:(void(^)(NSArray *list))success
                            failuer:(void(^)(NSString *error))failure {
    
    self.requestUrl = @"api/ZXYYTS/W_ZXYYTS_GetStandardPronunciationInfo";
    
    [self requestGetMethodWithSuccess:^(id responseObject) {
        
        NSArray *resp_list = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"kz_Net_Data:%@", resp_list);
        NSMutableArray *temp = [NSMutableArray new];
        for (int i = 0; i < resp_list.count; i ++) {
            KZPronounceDetailModel *model = [KZPronounceDetailModel yy_modelWithDictionary:resp_list[i]];
            [temp addObject:model];
        }
        success(temp.copy);
        
    } Failure:^(NSError *error) {
        NSLog(@"kz_Net_Error:%@", error.localizedDescription);
        failure(error.localizedDescription);
    }];
}

// 保存音标复习信息
- (void)saveStandarPronouncationInfo:(void(^)(void))success
                             failuer:(void(^)(NSString *error))failure {
    
    self.requestUrl = @"api/ZXYYTS/W_ZXYYTS_SaveStandardPronunciationInfo";
    
    [self requestPostMethodWithSuccess:^(id responseObject) {
        
        id resp = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"kz_Net_Data:%@", resp);

        success();
        
    } Failure:^(NSError *error) {
        NSLog(@"kz_Net_Error:%@", error.localizedDescription);
        failure(error.localizedDescription);
    }];
}

// 获取音标解析课件
- (void)getEngLetterAndPhone:(void(^)(NSDictionary *dic))success
                     failuer:(void(^)(NSString *error))failure {
    
    self.requestUrl = @"api/ZXYYTS/W_ZXYYTS_GetEngLetterAndPhone";
    
    NSLog(@"%@", [self.requestParam yy_modelToJSONString]);
    [self requestGetMethodWithSuccess:^(id responseObject) {
        
        NSArray *resp = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:nil];
        NSLog(@"kz_Net_Data:%@", resp);
        
        success(resp.firstObject);
        
    } Failure:^(NSError *error) {
        NSLog(@"kz_Net_Error:%@", error.localizedDescription);
        failure(error.localizedDescription);
    }];
}
@end
